unit uMain;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls,
  Graphics, Dialogs, Menus, ActnList, ComCtrls, DBActns, ExtCtrls, udm,db;

type

  { TFormMain }

  TFormMain = class(TForm)
    acBukaData: TAction;
    acStock: TAction;
    acTutup: TAction;
    ActMenu: TActionList;
    DataSetCancel1: TDataSetCancel;
    DataSetDelete1: TDataSetDelete;
    DataSetEdit1: TDataSetEdit;
    DataSetInsert1: TDataSetInsert;
    DataSetPost1: TDataSetPost;
    imgMain: TImageList;
    MenuItem1: TMenuItem;
    MenuItem10: TMenuItem;
    MenuItem2: TMenuItem;
    MenuItem3: TMenuItem;
    MenuItem4: TMenuItem;
    MenuItem5: TMenuItem;
    MenuItem6: TMenuItem;
    MenuItem7: TMenuItem;
    MenuItem8: TMenuItem;
    MenuItem9: TMenuItem;
    mmMain: TMainMenu;
    pnMain: TPanel;
    StatusBar1: TStatusBar;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    procedure acBukaDataExecute(Sender: TObject);
    procedure acStockExecute(Sender: TObject);
    procedure acTutupExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure MenuItem2Click(Sender: TObject);
    procedure MenuItem4Click(Sender: TObject);
    procedure MenuItem5Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
  private
    FActiveDataSet: TDataSet;
    procedure SetActiveDataSet(AValue: TDataSet);
    { private declarations }
  public
    property ActiveDataSet: TDataSet read FActiveDataSet write SetActiveDataSet;
    { public declarations }
  end; 

var
  FormMain: TFormMain;

implementation

{$R *.lfm}

uses
  uStock;

{ TFormMain }

procedure TFormMain.FormCreate(Sender: TObject);
begin
  with dmMargaria.Config do
  begin
    Filtered:=False;
    Filter:='ID=1';
    Filtered:=True;
    Self.Caption := dmMargaria.Configvalue.AsString;
  end;
end;

procedure TFormMain.MenuItem2Click(Sender: TObject);
begin
end;

procedure TFormMain.acStockExecute(Sender: TObject);
begin
  if FormStock = nil then
  begin
    FormStock := TFormStock.CreateParented(Self.pnMain.Handle);
    FormStock.Show;
    FormStock.WindowState:=wsMaximized;
  end
  else
    FormStock.BringToFront;
end;

procedure TFormMain.acTutupExecute(Sender: TObject);
begin
  acTutup.Enabled:=not acTutup.Enabled;
  acBukaData.Enabled:=not acBukaData.Enabled;

  ActiveDataSet.Close;
end;

procedure TFormMain.acBukaDataExecute(Sender: TObject);
begin
  acTutup.Enabled:=not acTutup.Enabled;
  acBukaData.Enabled:=not acBukaData.Enabled;

  ActiveDataSet.Open;
end;

procedure TFormMain.MenuItem4Click(Sender: TObject);
begin

end;

procedure TFormMain.MenuItem5Click(Sender: TObject);
begin

end;

procedure TFormMain.ToolButton1Click(Sender: TObject);
begin

end;

procedure TFormMain.SetActiveDataSet(AValue: TDataSet);
begin
  if FActiveDataSet=AValue then Exit;
  FActiveDataSet:=AValue;
  if FActiveDataSet = nil then
    acTutup.Enabled:=False;
  acBukaData.Enabled:=FActiveDataSet <> nil;
end;

end.

